package edu.sctu.wujiayi.month06.day20150628.javaText;

import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;

/**
 * Created by user11 on 2015/6/28.
 */
public class ThreadOne {
    public URL url;
    public String threadunit(String path){
        String json = "";
        try {
            try {
                Thread.sleep(5000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            url = new URL(path);
            HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection();

            InputStream inputStream = httpURLConnection.getInputStream();
            byte value[] = new byte[1];

            while (inputStream.read(value) != -1){
                json = json + new String(value);
            }
        } catch (MalformedURLException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return json;
    }

//    public static void main(String[] args) {
//        ThreadOne threadOne = new ThreadOne();
//        String value = threadOne.threadunit("http://api.ii.com.cn/goods/apprec?page=1&size=10");
//
//        System.out.println(value);
//    }
}
